Kinetis SDK API Reference Manual  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages

The section describes the programming interface of the SDCH Peripheral driver. More...

SDHC PD FUNCTION

sdhc_status_t sdhc_init (uint8_t instance, sdhc_host_t *host, const sdhc_user_config_t *config)
 Initializes the Host controller by a specific instance index. More...
 
void sdhc_shutdown (sdhc_host_t *host)
 Destroy host controller. More...
 
sdhc_status_t sdhc_check_card (sdhc_host_t *host, sdhc_card_t *card)
 check whether the card is present on specified host controller. More...
 
sdhc_status_t sdhc_check_ro (sdhc_host_t *host)
 Checks the read only for the attached card. More...
 
sdhc_status_t sdhc_config_host (sdhc_host_t *host, sdhc_host_config_t *config)
 Configures the specified host controller. More...
 
sdhc_status_t sdhc_issue_request (sdhc_host_t *host, sdhc_request_t *req)
 Issues the request on a specific Host controller and returns on completion. More...
 

SDHC Peripheral Driver

Overview

The SDHC driver configures the secure digital host controller and provides an easy way to operate the SDHC module.

Initialization

To initialize the SDHC module, call the sdhc_init() function and pass in the configuration data structure.
This is an example code to initialize and configure the driver:
// Define device configuration.
sdhc_init_config_t config = {0};
config.busWidth = SD_BUS_WIDTH_1BIT;
config.clock = 0;
// Initialize
if (sdhc_init(instance, &host, &config) != kStatus_SDHC_NoError)
{
/* error occurs */
}
else
{
/* SDHC has been successfully initialized */
}

Issuing a request to the card

The SDHC driver provides a simple way to send commands to and retrieve response/data from the card.This is a example to send the SD_SWITCH command to the card.

sdhc_request_t req = {0};
sdhc_command_t cmd = {0};
sdhc_data_t data = {0};
cmd.index = kSdSwitch; /* Set command index */
cmd.argument = mode << 31 | 0x00FFFFFF; /* Set argument */
cmd.argument &= ~((0xF) << (group * 4));
cmd.argument |= value << (group * 4);
cmd.flags = SDMMC_RSP_R1 | SDMMC_CMD_ADTC; /* Set command flags */
data.blockSize = 64; /* Set data block size */
data.blockCount = 1; /* Set data block count */
data.flags = SDMMC_DATA_READ; /* Set data direction */
data.buffer = response; /* Set data buffer */
/* link data, command with request */
data.req = &req;
data.cmd = &cmd;
req.cmd = &cmd;
req.data = &data;
cmd.data = &data;
if (kStatus_SDHC_NoError != sdhc_issue_request(host, &req)) /* issue reqeust */
{
/* error occurs */
}
else
{
/* request has been issued successfully */
}

Function Documentation

sdhc_status_t sdhc_init ( uint8_t  instance,
sdhc_host_t host,
const sdhc_user_config_t config 
)

This function initializes the SDHC module according to the given initialization configuration structure including the clock frequency, bus width, and card detect callback.

Parameters
instancethe specific instance index
hostthe memory address allocated for the host handle
configinitialization configuration data
Returns
kStatus_SDHC_NoError if success
void sdhc_shutdown ( sdhc_host_t host)
Parameters
hostthe pointer to the host controller about to be destroyed
sdhc_status_t sdhc_check_card ( sdhc_host_t host,
sdhc_card_t card 
)

This function checks if there's a card inserted to the SDHC.

Parameters
hostthe pointer to the host controller
cardthe pointer to retrieve card information
Returns
kStatus_SDHC_NoError on success
sdhc_status_t sdhc_check_ro ( sdhc_host_t host)
Parameters
hostthe pointer to the host controller
Returns
kStatus_SDHC_NoError on success
sdhc_status_t sdhc_config_host ( sdhc_host_t host,
sdhc_host_config_t config 
)

With this function, a user can modify the specific SDHC configuration.

Parameters
hostthe pointer to the host controller
configthe pointer to the configuration information
Returns
kStatus_SDHC_NoError on success
sdhc_status_t sdhc_issue_request ( sdhc_host_t host,
sdhc_request_t req 
)

This function issues the request to the card on a specific SDHC. The command is sent and is blocked as long as the response/data is sending back from the card.

Parameters
hostthe pointer to the host controller
reqthe pointer to the request
Returns
kStatus_SDHC_NoError on success